<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<%-- <%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> --%>

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>挂靠公司详细信息</title>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>
<body class="iframeBody">
<div class="Wrapper">
    <div id="pageInTab" class="pageInTab">
        <div tabid="tabA" title="基本信息" id="tabAId">
            <form id="prj_lnk_comp_form">
                <div class="fieldset1 tabel_col clearFix">
                    <div class="fieldBox col_50">
                        <div class="label">公司名称</div>
                        <div class="field">
                            <input name="lnkCompNm" id="lnkCompNm" type="text" class="ui-textbox"
                                   value="${prjLnkComp.lnkCompNm }" validate="{required:true}">
                            <span class="requiredSymbol">*</span>
                        </div>
                    </div>
                    <div class="fieldBox col_50">
                        <div class="label">组织机构代码</div>
                        <div class="field">
                            <input name="orgCode" id="orgCode" type="text" class="ui-textbox"
                                   value="${prjLnkComp.orgCode}" validate="{required:true}">
                            <span class="requiredSymbol">*</span>
                        </div>
                    </div>

                    <div class="fieldBox col_50">
                        <div class="label">公司归属</div>
                        <div class="field">
                            <select name="ownerCd" id="ownerCd">
                                <c:forEach items="${keyValueList}" var="opt">
                                    <option value="${opt.key}"
                                            <c:if test="${opt.key==prjLnkComp.ownerCd }">selected="selected"</c:if>
                                    >${opt.value}</option>
                                </c:forEach>
                            </select>
                            <span class="requiredSymbol" isShow="iscar">*</span>
                        </div>
                    </div>
                    <div class="fieldBox col_50">
                        <div class="label">所在地</div>
                        <div class="field">
                            <input name="officeAddr" id="officeAddr" type="text" isShow="iscar" class="ui-textbox"
                                   value="${prjLnkComp.officeAddr }">
                            <span class="requiredSymbol" isShow="iscar">*</span>
                        </div>
                    </div>
                    <div class="fieldBox col_50">
                        <div class="label">主营项目类别</div>
                        <div class="field">
                            <input name="majorBiz" id="majorBiz" type="text" class="ui-textbox"
                                   value="${prjLnkComp.majorBiz }">
                        </div>
                    </div>
                    <div class="fieldBox col_50">
                        <div class="label">企业类型</div>
                        <div class="field">
                            <input name="compTyp" id="compTyp" type="text" class="ui-textbox"
                                   value="${prjLnkComp.compTyp }">
                        </div>
                    </div>
                    <div class="fieldBox col_50">
                        <div class="label">营业执照注册号</div>
                        <div class="field">
                            <input name="bizLicNo" id="bizLicNo" type="text" isShow="isother" class="ui-textbox"
                                   value="${prjLnkComp.bizLicNo }" validate="{required:true}">
                            <span class="requiredSymbol" isShow="isother">*</span>
                        </div>
                    </div>
                    <div class="fieldBox col_50">
                        <div class="label">注册地址</div>
                        <div class="field">
                            <input name="regAddr" id="regAddr" type="text" class="ui-textbox"
                                   value="${prjLnkComp.regAddr }">
                        </div>
                    </div>
                    <div class="fieldBox col_50">
                        <div class="label">成立日期</div>
                        <div class="field">
                            <input name="regDt" id="regDt" type="text" isShow="iscar" class="ui-datepicker"
                                   value="${prjLnkComp.regDt }">
                            <span class="requiredSymbol" isShow="iscar">*</span>
                        </div>
                    </div>
                    <div class="fieldBox col_50">
                        <div class="label">税务登记号</div>
                        <div class="field">
                            <input name="taxRegNo" id="taxRegNo" type="text" class="ui-textbox"
                                   value="${prjLnkComp.taxRegNo }" validate="{required:true}">
                            <span class="requiredSymbol">*</span>
                        </div>
                    </div>
                    <div class="fieldBox col_50">
                        <div class="label">道路运输许可证有效期</div>
                        <div class="field">
                            <input name="expDt" id="expDt" type="text" isShow="isother" class="ui-datepicker"
                                   value="${prjLnkComp.expDt }" validate="{required:true}">
                            <span class="requiredSymbol" isShow="isother">*</span>
                        </div>
                    </div>
                    <div class="fieldBox col_50">
                        <div class="label">经营范围</div>
                        <div class="field">
                            <input name="bizScope" id="bizScope" type="text" class="ui-textbox"
                                   value="${prjLnkComp.bizScope }">
                        </div>
                    </div>
                    <div class="fieldBox col_50" rlPsnDiv="zk">
                        <div class="label"> 法人代表</div>
                        <div class="field">
                            <input name="corpRep" id="corpRep" type="text" isShow="iscar" class="ui-textbox"
                                   value="${prjLnkComp.corpRep }">
                            <span class="requiredSymbol" isShow="iscar">*</span>
                        </div>
                    </div>
                    <div class="fieldBox col_50" rlPsnDiv="zk">
                        <div class="label">法人身份证号</div>
                        <div class="field">
                            <input name="idNo" id="idNo" type="text" class="ui-textbox" value="${prjLnkComp.idNo }">
                        </div>
                    </div>

                    <div class="fieldBox col_50">
                        <div class="label">现累计挂靠数量</div>
                        <div class="field">
                            <input name="totLnkQty" id="totLnkQty" type="text" class="ui-textbox"
                                   value="${prjLnkComp.totLnkQty }">
                        </div>
                    </div>
                    <div class="fieldBox col_50">
                        <div class="label">自有车辆备案数量</div>
                        <div class="field">
                            <input name="ownQty" id="ownQty" type="text" class="ui-textbox"
                                   value="${prjLnkComp.ownQty }">
                        </div>
                    </div>
                    <div class="fieldBox col_50">
                        <div class="label">在我司累积挂靠车辆</div>
                        <div class="field">
                            <input name="ourTotLnkQyt" id="ourTotLnkQyt" type="text" class="ui-textbox"
                                   value="${prjLnkComp.ourTotLnkQyt }">
                        </div>
                    </div>
                    <div class="fieldBox col_66_auto">
								<div class="label">区域</div>
								<div class="field">
									<!-- <input name="rgnPrCd" id="rgnPrCd" type="text" class="ui-textbox" value=""> -->
									<jsp:include page="../../system/sysRegion/region.jsp"
										flush="true">
										<jsp:param name="regionShowLvl" value="2" />
									</jsp:include>
									<span class="requiredSymbol">*</span>
								</div>
					</div>
                    <div class="fieldBox col_50" rlPsnDiv="zk">
                        <div class="label">实际控制人</div>
                        <div class="field">
                            <input name="actCtrlNm" id="actCtrlNm" type="text" class="ui-textbox"
                                   value="${prjLnkComp.actCtrlNm}" validate="{required:true}">
                            <span class="requiredSymbol">*</span>
                        </div>
                    </div>
                    <div class="fieldBox col_50" rlPsnDiv="zk">
                        <div class="label">实际控制人手机号码</div>
                        <div class="field">
                            <input name="actCtrlMp" id="actCtrlMp" type="text" class="ui-textbox"
                                   value="${prjLnkComp.actCtrlMp }" validate="{required:true}">
                            <span class="requiredSymbol">*</span>
                        </div>
                    </div>
                    <div class="fieldBox col_50" rlPsnDiv="zk">
                        <div class="label">联系人</div>
                        <div class="field">
                            <input name="lnkNm" id="lnkNm" type="text" class="ui-textbox" value="${prjLnkComp.lnkNm }">
                        </div>
                    </div>
                    <div class="fieldBox col_50" rlPsnDiv="zk">
                        <div class="label">联系人手机号码</div>
                        <div class="field">
                            <input name="lnkMp" id="lnkMp" type="text" isShow="iscar" class="ui-textbox"
                                   value="${prjLnkComp.lnkMp }">
                            <span class="requiredSymbol" isShow="iscar">*</span>
                        </div>
                    </div>
                    <div class="fieldBox col_50" rlPsnDiv="zk">
                        <div class="label"> 联系人职务</div>
                        <div class="field">
                            <input name="lnkPost" id="lnkPost" type="text" class="ui-textbox"
                                   value="${prjLnkComp.lnkPost }">
                        </div>
                    </div>
                    <div class="fieldBox col_100">
                        <div class="label">备注</div>
                        <div class="field">
                            <textarea name="rem" id="rem" rows="4" class="ui-textarea l-textarea" style="width:80%"
                                      value="">${prjLnkComp.rem } </textarea>
                        </div>
                    </div>
                </div>
                <div class="fieldBox col_100" style="display:none;">
                    <div class="field">
                        <input name="lnkCompId" id="lnkCompId" type="text" class="ui-textbox" value="${prjLnkComp.id }">
                    </div>
                </div>
                <div class="fieldBox col_100" id="psnDiv" style="display:none">
                    <div class="sqPanel">
                        <div class="sqPanel_head inL">
                            <div class="btnsBox inLC">
                                <span id="addBtn" onclick="addBtn();" class="sq-button sq-button-round">添加</span>
                            </div>
                            <span>主要人员信息</span>
                        </div>
                        <br/>
                        <br/>
                        <div id="psnGrid">
                            <div id="ligergrid_psn" class="sq-grid"></div>
                        </div>
                    </div>
                </div>
                <div class="fieldset1 tabel_col tabel_col_s clearFix">
                    <div class="caption">
                        <span class="title">上传附件信息 </span>
                    </div>
                    <div class="fieldBox col_100" id="fileDetail">
                        <div class="label">资料上传</div>
                        <div class="field">
                            <jsp:include page="../../system/sysUlFilesRec/sysSysUlFilesRecUpload2.jsp" flush="true">
                                <jsp:param name="filePath" value="lnkcomp"/>
                            </jsp:include>
                            <input name="lnkCompId" id="lnkCompId" type="hidden" class="ui-textbox"
                                   value="${prjLnkComp.id }">
                        </div>
                    </div>

                    <div class="fieldBox col_100" id="fileModify">
                        <div class="label">资料</div>
                        <div class="field">
                            <jsp:include page="../../system/sysUlFilesRec/sysUlFileRecList.jsp" flush="true">
                                <jsp:param name="pkId" value="${prjLnkComp.id }"/>
                                <jsp:param name="tabNm" value="PRJ_LNK_COMP"/>
                            </jsp:include>
                        </div>
                    </div>
                </div>

                <div class="btnsBox">
                    <span id="prj_lnk_comp_add_btn_id" class="sq-button sq-button-round" onclick="lnkwsCheck();"><!-- <i class="sqBtnIco_10"></i> -->保存</span>
                    <span id="prj_lnk_comp__cancel_btn_id" class="sq-button sq-button-round" onclick="cancelBtn();"><!-- <i class="sqBtnIco_14"></i> -->取消</span>
                </div>
            </form>
        </div>
        <div tabid="tabB" title="相关项目" id="tabBId">
            <iframe frameborder="0" name="tabB" id="tabB" src=""></iframe>
        </div>
        <div tabid="tabC" title="备案账号" id="tabCId">
            <iframe frameborder="0" name="tabC" id="tabC" src=""></iframe>
        </div>
        <div tabid="tabD" title="敞口历史" id="tabDId">
            <iframe frameborder="0" name="tabD" id="tabD" src=""></iframe>
        </div>
        <div tabid="tabE" title="人工干预" id="tabEId">
            <iframe frameborder="0" name="tabE" id="tabE" src=""></iframe>
        </div>
    </div>
</div>
</div>

<script type="text/javascript">

    var BuOrgCd = '${BuOrgCd}';
    var audStsCd = '${audStsCd}';
    var rlPsnGrid;
    var rlPsnList = null;
    var isFlow = '${isFlow}';
    if ('${rlPsnList}') {
        rlPsnList =${rlPsnList};
    }
    var certTypCdList =${certTypCdList};
    var rlRsnTypListJSON =${rlRsnTypListJSON};
    var rlRsnTypList = [];
    if ('${rlRsnTypList}') {
        rlRsnTypList = JSON.parse('${rlRsnTypList}');
    }
    var pageInApp = {
        flag: true
    };
    $(function () {

        initStyle();

        initData();
        var lnkCompId = $("#lnkCompId").val();
        initRlPsnGrid(rlPsnList);
    });

    function initStyle() {
        $("span[isShow='iscar']").each(function () {
            $("input[isShow='iscar']").each(function () {
                $(this).attr("validate", "");
            });
            $(this).hide();
        });
        $("span[isShow='isother']").each(function () {
            $("input[isShow='isother']").each(function () {
                $(this).attr("validate", "{required:true}");
            });
            $(this).show();
        });

        $("div[rlPsnDiv='zk'] div input").each(function () {
            $(this).attr("validate", "");
        });
        $("#psnDiv").show();
    }

    var pageInTab = null;
    var loadedTabs = []

    //初始化数据
    function initData() {

        setFormatDateValue();
        $("#prj_lnk_comp_form").ligerForm({
            validate: true
        });
        var id = $("#lnkCompId").val();
        if (!id) {
            var baseForm1 = liger.get("prj_lnk_comp_form");
            baseForm1.setData({
                ownerCd: ProjectConstant.CODE_OWNER_CD
            });
            //设置公司归属默认为第三方
        }
        setRgnProvCdUpdataValue(data.rgnPrCd);
    	setRgnCityCdUpdataValue(data.rgnCyCd);
        initTab();
        pageInTab.removeTabItem("tabC");

    }

    //初始化Tab
    function initTab() {
        pageInTab = $("#pageInTab").ligerTab({
            height: 'auto',
            contextmenu: false,
            minIframeHeight: GET_minIframeHeight(),
            onBeforeSelectTabItem: function (tabid) {
                var lnkCompId = $("#lnkCompId").val();
                if (tabid != "tabA") {
                    if (lnkCompId == null || lnkCompId == '') {
                        top.$.ligerDialog.SQalert({content: LogUtils.LOG_LNK_COMP_SELECT_BEFORE, SQ_type: "warning"});
                        return false;
                    }
                }
            },
            onAfterSelectTabItem: function (tabid) {
                //   if (loadedTabs.indexOf(tabid)<0) {
                var lnkCompId = $("#lnkCompId").val();
                if (tabid != "tabA") {
                    if (lnkCompId == null || lnkCompId == '') {
                        top.$.ligerDialog.SQalert({content: LogUtils.LOG_LNK_COMP_SELECT_BEFORE, SQ_type: "warning"});
                        return false; //验证不通过，不执行以下代码
                    }
                }
                loadedTabs.push(tabid);
                switch (tabid) {
                    case "tabB":
                        pageInTab.setTabItemSrc(tabid, "<%=path%>/project/prjbscinfo/toPrjBscInfoListPage.do?lnkCompId=" + lnkCompId + "&&isLnkCompFlag=1");
                        break;
                    case "tabC":
                        pageInTab.setTabItemSrc(tabid, "<%=path%>/project/prjLnkCompBkAcc/toListPage.do?compId=" + lnkCompId);
                        break;
                    case "tabD":
                        pageInTab.setTabItemSrc(tabid, "<%=path%>/project/prjLnkCompCrLim/toListPage.do?compId=" + lnkCompId);
                        break;
                    case "tabE":
                        pageInTab.setTabItemSrc(tabid, "<%=path%>/customer/cstManualRelation/toListPage.do?Id=" + lnkCompId +"&useType=3&cstType=2");
                        break;
                }
                //     };
                SetIframe_height();
            }
        });

        $.extend(true, pageInApp, {
            pageInTab: pageInTab
        });
    };

    //设置日期值
    function setFormatDateValue() {
        var regDt = $("#regDt").val();
        var expDt = $("#expDt").val();
        if (expDt) {
            var expDate = DateUtils.formatDate(new Date(expDt), DateUtils.YYYY_MM_DD);
            $("#expDt").val(expDate);//道路运输许可证有效期
        }
        if (regDt) {
            var regDate = DateUtils.formatDate(new Date(regDt), DateUtils.YYYY_MM_DD);
            $("#regDt").val(regDate);//注册日期
        }

    }

    //检查是否重名
    function checkPrjLnkCompNm() {
        var flag = false;
        var lnkCompNm = $("#lnkCompNm").val();
        var url = '<%=path%>/project/prjlnkcomp/checkPrjLnkCompNm.do';
        var data = {};
        data.lnkCompNm = lnkCompNm;
        if (lnkCompNm) {
            $.ajax({
                type: 'get',
                dataType: 'json',
                data: data,
                url: url,
                success: function (msg) {
                    if (msg.success == 1) {
                        if (msg.data) {
                            top.$.ligerDialog.SQalert({content: "该挂靠公司已经存在", SQ_type: "error"});
                            flag = true;
                        }
                    }
                }
            });
        }
        return flag;
    }

    //取消
    function cancelBtn() {
        var TAB = top.mainApp.parentTab;
        var currentTabid = TAB.getSelectedTabItemID();
        top.tab.removeTabItem(currentTabid);
    }
    function lnkwsCheck() {
        var ligerForm = liger.get("prj_lnk_comp_form");
        var rlPsnData = rlPsnGrid.getData();
        var _data = ligerForm.getData();
        _data["rlPsnList"] = JSON.stringify(rlPsnData);

        var _url = '<%=path%>/project/prjlnkcomp/kingDeeWsCheckLnk.do';

        $.ajax({
            type: 'post',
            url: _url,
            data: _data,
            dataType: "json",
            success: function (msg) {
                if ( 0 == msg.success) {
                    $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
                    return false;
                }else if( 1 == msg.success ){
                    save();
                }
            }
        });
    }
    function save() {
        var ligerForm = liger.get("prj_lnk_comp_form");
        if (!ligerForm.valid()) {
            top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO, SQ_type: "warning"});
            return false; //验证不通过，不执行以下代码
        }
        var rlPsnData = rlPsnGrid.getData();
        var lnkCompNm = $("#lnkCompNm").val();
        var lnkCompId = $("#lnkCompId").val();
        if (lnkCompId) {
            var data = ligerForm.getData();
            data["regDt"] = $("#regDt").val();
            data["expDt"] = $("#expDt").val();
            //event.preventDefault();

            var fileParams = getUploadResultParams();//获取附件上传的信息
            data["fileParams"] = JSON.stringify(fileParams);
              if(BuOrgCd!=ProjectConstant.CODE_BU_ORG_CD_XNY){
            var isValid = SQ.validGrid('ligergrid_psn');
            if (isValid == false) {
                UIUtils.alertError("请正确填写！");
                return false;
            }
            data["rlPsnList"] = JSON.stringify(rlPsnData);
              }
            var url = '<%=path%>/project/prjlnkcomp/modifyPrjLnkComp.do';
            var lnkCompId = $("#lnkCompId").val();
            data["lnkCompId"] = lnkCompId;

            var wait_dialog;
            $.ajax({
                type: 'post',
                dataType: 'json',
                data: data,
                url: url,
                beforeSend: function () {
                    wait_dialog = $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING, SQ_type: "waitting"});
                },
                success: function (msg) {
                    wait_dialog.close();
                    if (msg.success == 1) {
                        top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "success"});
                        if (!isFlow) {
                            var TAB = top.mainApp.parentTab;
                            var currentTabid = TAB.getSelectedTabItemID();
                            var currFrameElement = top.$("#" + currentTabid).get(0);
                            var callback = currFrameElement.W2W.callback;
                            callback();
                            top.tab.removeTabItem(currentTabid);
                        }
                    } else {
                        top.$.ligerDialog.SQalert({content: msg.info, SQ_type: "error"});
                    }
                }
            });
        }
    }

    function initRlPsnGrid(data) {
        rlPsnGrid = $("#ligergrid_psn").ligerGrid({
            data: data,
            columns: [
                {
                    display: '姓名(<span class="c_red">*</span>)', name: 'rlNm', minWidth: 60, editor: {type: 'text'},
                    validate: function (value) {
                        if (StringUtils.isEmpty(value)) return "此项为必填项！";
                    }
                },
                {
                    display: '联系人类型(<span class="c_red">*</span>)', name: 'rlTypCdNm', minWidth: 60,
                    editor: {
                        type: 'select',
                        data: rlRsnTypListJSON,
                        valueField: 'key',
                        textField: 'value'
                    },
                    valueField: 'rlTypCd',
                    textField: 'rlTypCdNm',
                    render: function (item) {
                        return item.rlTypCdNm;
                    },
                    validate: function (value) {
                        if (StringUtils.isEmpty(value)) return "此项为必填项！";
                    }
                },
                {display: '股比',name:'stockRatio',width:100},
                {
                    display: '证件类型(<span class="c_red">*</span>)', name: 'certTypCdNm', minWidth: 60,
                    editor: {
                        type: 'select',
                        data: certTypCdList,
                        valueField: 'key',
                        textField: 'value'
                    },
                    valueField: 'certTypCd',
                    textField: 'certTypCdNm',
                    render: function (item) {
                        return item.certTypCdNm;
                    },
                    validate: function (value) {
                        if (StringUtils.isEmpty(value)) return "此项为必填项！";
                    }
                },
                {
                    display: '证件号码(<span class="c_red">*</span>)',
                    name: 'certNo',
                    width: 140,
                    align: 'left',
                    editor: {type: 'text'},
                    validate: function (value) {
                        if (StringUtils.isEmpty(value)) return "此项为必填项！";
                    }
                },
                {
                    display: '联系电话(<span class="c_red">*</span>)',
                    name: 'tel',
                    width: 100,
                    align: 'left',
                    editor: {type: 'text'},
                    validate: function (value) {
                        if (StringUtils.isEmpty(value)) return "此项为必填项！";
                    }
                },
                {display: '备注', name: 'rlRem', minWidth: 140, editor: {type: 'text'}},
                getOptColumn()
            ],
            onBeforeSubmitEdit: function (e) {//重新赋值,要不然选中后离开会把key显示在前端
                if (e.selected && e.column.columnname == "certTypCdNm") {
                    e.record.certTypCdId = e.value;
                    e.value = e.selected[e.column.editor.textField];
                    e.record.certTypCd = e.record.certTypCdId;
                }
                if (e.selected && e.column.columnname == "rlTypCdNm") {
                    e.record.rlTypCdId = e.value;
                    e.value = e.selected[e.column.editor.textField];
                    e.record.rlTypCd = e.record.rlTypCdId;
                }
            },
            onBeforeEdit: function (e) {
                e.lastValue = e.value;
                e.index = e.rowindex;
                e.column.editor.readonly = false;
                var colNanme = e.column.columnname;
                if (e.record.isSysDef == 1) {
                    if (colNanme == "rlTypCdNm") {
                        e.column.editor.readonly = true;
                    }
                }
            },

            pageSize: 100,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            heightDiff: -2,
            checkbox: false,
            enabledEdit: true,
            allowUnSelectRow: true,
            alternatingRow: false,
            rownumbers: true,
            enabledSort: false,
            usePagerOnLessPagesize: false,
        });
        rlPsnGrid.setHeight(200);
    }

    function initRlPsnCarGrid(data) {
        rlPsnGrid = $("#ligergrid_psn").ligerGrid({
            data: data,
            columns: [
                {display: '姓名(<span class="c_red">*</span>)', name: 'rlNm', minWidth: 60, editor: {type: 'text'}},
                {
                    display: '联系人类型(<span class="c_red">*</span>)', name: 'rlTypCdNm', minWidth: 60,
                    editor: {
                        type: 'select',
                        data: rlRsnTypListJSON,
                        valueField: 'key',
                        textField: 'value'
                    },
                    valueField: 'rlTypCd',
                    textField: 'rlTypCdNm',
                    render: function (item) {
                        return item.rlTypCdNm;
                    },
                    validate: function (value) {
                        if (value == '' || value == undefined) return "此项为必填项！";
                    }
                },
                {
                    display: '证件类型(<span class="c_red">*</span>)', name: 'certTypCdNm', minWidth: 60,
                    editor: {
                        type: 'select',
                        data: certTypCdList,
                        valueField: 'key',
                        textField: 'value'
                    },
                    valueField: 'certTypCd',
                    textField: 'certTypCdNm',
                    render: function (item) {
                        return item.certTypCdNm;
                    },
                    validate: function (value) {
                        if (value == '' || value == undefined) return "此项为必填项！";
                    }
                },
                {
                    display: '证件号码(<span class="c_red">*</span>)',
                    name: 'certNo',
                    width: 140,
                    align: 'left',
                    editor: {type: 'text'}
                },
                {
                    display: '联系电话(<span class="c_red">*</span>)',
                    name: 'tel',
                    width: 100,
                    align: 'left',
                    editor: {type: 'text'},
                    validate: function (value) {
                        if (value == '' || value == undefined) return "此项为必填项！";
                    }
                },
                {display: '备注', name: 'rlRem', minWidth: 140, editor: {type: 'text'}},
                getOptColumn()
            ],
            onBeforeSubmitEdit: function (e) {//重新赋值,要不然选中后离开会把key显示在前端
                if (e.selected && e.column.columnname == "certTypCdNm") {
                    e.record.certTypCdId = e.value;
                    e.value = e.selected[e.column.editor.textField];
                    e.record.certTypCd = e.record.certTypCdId;
                }
                if (e.selected && e.column.columnname == "rlTypCdNm") {
                    e.record.rlTypCdId = e.value;
                    e.value = e.selected[e.column.editor.textField];
                    e.record.rlTypCd = e.record.rlTypCdId;
                }
            },
            onBeforeEdit: function (e) {
                e.lastValue = e.value;
                e.index = e.rowindex;
                e.column.editor.readonly = false;
                var colNanme = e.column.columnname;
                if (e.record.isSysDef == 1) {
                    if (colNanme == "rlTypCdNm") {
                        e.column.editor.readonly = true;
                    }
                }
            },
            pageSize: 100,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            heightDiff: -2,
            checkbox: false,
            enabledEdit: true,
            allowUnSelectRow: true,
            alternatingRow: false,
            rownumbers: true,
            enabledSort: false,
            usePagerOnLessPagesize: false,
        });
        rlPsnGrid.setHeight(200);
    }


    //获取操作列
    function getOptColumn() {
        var column = {
            display: '操作',
            isSort: false,
            width: 150,
            align: 'left',
            render: function (rowdata, rowindex, value) {
                var h = "";
                //if(!rowdata.isSysDef||rowdata.isSysDef==0){
                h += '<a class="sq-button-hasicon" href="javascript:removeBtn(';
                h += "'" + rowdata.id + "'";
                h += ')"><i class="sqBtnIco_7"></i>删除</a>'
                // }
                return h;
            }
        }
        return column;
    }

    function removeBtn() {
        var selectedRows = rlPsnGrid.getSelectedRows();
        if (selectedRows.length != 1) {
            $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_ONLY_A_ROW, SQ_type: "warring"});
            return;
        }
        $.ligerDialog.confirm(LogUtils.LOG_CMM_DELETE_CONFIRM, function (flag) {
            if (flag == false) return;
            if (selectedRows[0].id) {
                //删除数据
                var _ids = [];
                for (var index in selectedRows) {
                    _ids.push(selectedRows[index].id);
                }
                $.ajax({
                    type: 'post',
                    dataType: 'json',
                    data: {ids: JSON.stringify(_ids)},
                    url: '<%=path%>/project/prjLnkCompRlPsn/removeByIds.do',
                    success: function (msg) {
                        if (msg.success == 1) {
                            rlPsnGrid.deleteSelectedRow();
                            UIUtils.alertSuccess(msg.info);
                        } else {
                            UIUtils.alertError(msg.info);
                        }
                    }
                });

            } else {
                rlPsnGrid.deleteSelectedRow();
            }
        });
    }

    function addBtn() {
        //添加联系人信息
        var manager = $("#ligergrid_psn").ligerGetGridManager();
        manager.addRow({
            rlNm: '',
            rlTypCd: '',
            certTypCd: '',
            certNo: '',
            tel: '',
            rlRem: '',
        });
    }


</script>
</body>
</html>